/*
 *中北大学软件学院 版权所有2021 
 */
package com.ychs.uolab.user.service;

import static org.junit.Assert.assertFalse;

import java.util.List;

import com.ychs.uolab.user.dao.UserDao;
import com.ychs.uolab.user.dao.UserDaoImpl;
import com.ychs.uolab.user.vo.User;

/**
 *
 * @author cyq
 * @version 1.0
 * @date 2021年1月26日
 */
public class UserServiceImpl implements UserService {
    
	/**创建UserDaoImpl对象，以便UserServiceImpl来使用它
	/*多态机制 这种写法在Spring中大量使用
	 * 
	 */
	private UserDao userDao = new UserDaoImpl();
    
	
	@Override
	public boolean checkUser(String userName, String userPsw) {
		// TODO Auto-generated method stub
		
		//调用UserDao里的方法login
		boolean flag = userDao.login(userName, userPsw);
		return flag;
	}
    

	@Override
	public boolean adduser(User user) {
		// TODO Auto-generated method stub
		boolean flag = userDao.insertUser(user);
	    
		return flag;
	}


	@Override
	public int modifyUser(User user) {
		// TODO Auto-generated method stub
		int count = userDao.updateUser(user);

		return count;
	}


	@Override
	public int deleteuser(int userid) {
		// TODO Auto-generated method stub
		int count = userDao.deleteuser(userid);		
		
		return count;
	}


	@Override
	public List<User> findUser(String username, String dname, String major, String classes, String grade) {
		// TODO Auto-generated method stub
		List<User> ulist = userDao.selectUser(username, dname, major, classes, grade);
		
		return ulist;
	}

}
